auto.waitFor();
var storage = storages.create("xiangxiangyuedu");

function task(){
    var 首页 = text("首页").findOnce();
    if(首页){
        首页.click();
    }
    sleep(1000)
    var thisEle = text("开始挖矿").findOnce();
    if (thisEle) {
            toastLog("开始挖矿")
            click(thisEle.bounds().centerX(),thisEle.bounds().centerY());
            sleep(2000)
    }
    sleep(2000)
    var thisEle = text("领取收益").findOnce();
    if (thisEle) {
            toastLog("领取收益")
            click(thisEle.bounds().centerX(),thisEle.bounds().centerY());
            sleep(9000)
    }
    var thisEle = text("开始挖矿").findOnce();
    if (thisEle) {
            toastLog("开始挖矿")
            click(thisEle.bounds().centerX(),thisEle.bounds().centerY());
            sleep(2000)
    } 
}


function main() {
    let open_app = launchApp("IPCP");
    if (open_app) {
      task()
    }
    else {
      toastLog("IPCP开失败，请确认是否安装并授权打开!");
    }
  }
  
try {
    main();
  } catch (error) {
    toastLog(error);
  }
  
  storage.put("script_running_status", "end");